package abs.dao;

import abs.domain.Documentos;

import java.util.Arrays;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.Set;

import javax.persistence.EntityManager;
import javax.persistence.NoResultException;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;

import org.skyway.spring.util.dao.AbstractJpaDao;

import org.springframework.dao.DataAccessException;

import org.springframework.stereotype.Repository;

import org.springframework.transaction.annotation.Transactional;

/**
 * DAO to manage Documentos entities.
 * 
 */
@Repository("DocumentosDAO")
@Transactional
public class DocumentosDAOImpl extends AbstractJpaDao<Documentos> implements
		DocumentosDAO {

	/**
	 * Set of entity classes managed by this DAO.  Typically a DAO manages a single entity.
	 *
	 */
	private final static Set<Class<?>> dataTypes = new HashSet<Class<?>>(Arrays.asList(new Class<?>[] { Documentos.class }));

	/**
	 * EntityManager injected by Spring for persistence unit absV2
	 *
	 */
	@PersistenceContext(unitName = "absV2")
	private EntityManager entityManager;

	/**
	 * Instantiates a new DocumentosDAOImpl
	 *
	 */
	public DocumentosDAOImpl() {
		super();
	}

	/**
	 * Get the entity manager that manages persistence unit 
	 *
	 */
	public EntityManager getEntityManager() {
		return entityManager;
	}

	/**
	 * Returns the set of entity classes managed by this DAO.
	 *
	 */
	public Set<Class<?>> getTypes() {
		return dataTypes;
	}

	/**
	 * JPQL Query - findDocumentosByCo030desc
	 *
	 */
	@Transactional
	public Set<Documentos> findDocumentosByCo030desc(String co030desc) throws DataAccessException {

		return findDocumentosByCo030desc(co030desc, -1, -1);
	}

	/**
	 * JPQL Query - findDocumentosByCo030desc
	 *
	 */

	@SuppressWarnings("unchecked")
	@Transactional
	public Set<Documentos> findDocumentosByCo030desc(String co030desc, int startResult, int maxRows) throws DataAccessException {
		Query query = createNamedQuery("findDocumentosByCo030desc", startResult, maxRows, co030desc);
		return new LinkedHashSet<Documentos>(query.getResultList());
	}

	/**
	 * JPQL Query - findDocumentosByCo030feadAfter
	 *
	 */
	@Transactional
	public Set<Documentos> findDocumentosByCo030feadAfter(java.util.Calendar co030fead) throws DataAccessException {

		return findDocumentosByCo030feadAfter(co030fead, -1, -1);
	}

	/**
	 * JPQL Query - findDocumentosByCo030feadAfter
	 *
	 */

	@SuppressWarnings("unchecked")
	@Transactional
	public Set<Documentos> findDocumentosByCo030feadAfter(java.util.Calendar co030fead, int startResult, int maxRows) throws DataAccessException {
		Query query = createNamedQuery("findDocumentosByCo030feadAfter", startResult, maxRows, co030fead);
		return new LinkedHashSet<Documentos>(query.getResultList());
	}

	/**
	 * JPQL Query - findDocumentosByCo030feadBefore
	 *
	 */
	@Transactional
	public Set<Documentos> findDocumentosByCo030feadBefore(java.util.Calendar co030fead) throws DataAccessException {

		return findDocumentosByCo030feadBefore(co030fead, -1, -1);
	}

	/**
	 * JPQL Query - findDocumentosByCo030feadBefore
	 *
	 */

	@SuppressWarnings("unchecked")
	@Transactional
	public Set<Documentos> findDocumentosByCo030feadBefore(java.util.Calendar co030fead, int startResult, int maxRows) throws DataAccessException {
		Query query = createNamedQuery("findDocumentosByCo030feadBefore", startResult, maxRows, co030fead);
		return new LinkedHashSet<Documentos>(query.getResultList());
	}

	/**
	 * JPQL Query - findDocumentosByCo030lomoContaining
	 *
	 */
	@Transactional
	public Set<Documentos> findDocumentosByCo030lomoContaining(String co030lomo) throws DataAccessException {

		return findDocumentosByCo030lomoContaining(co030lomo, -1, -1);
	}

	/**
	 * JPQL Query - findDocumentosByCo030lomoContaining
	 *
	 */

	@SuppressWarnings("unchecked")
	@Transactional
	public Set<Documentos> findDocumentosByCo030lomoContaining(String co030lomo, int startResult, int maxRows) throws DataAccessException {
		Query query = createNamedQuery("findDocumentosByCo030lomoContaining", startResult, maxRows, co030lomo);
		return new LinkedHashSet<Documentos>(query.getResultList());
	}

	/**
	 * JPQL Query - findDocumentosByCo030fead
	 *
	 */
	@Transactional
	public Set<Documentos> findDocumentosByCo030fead(java.util.Calendar co030fead) throws DataAccessException {

		return findDocumentosByCo030fead(co030fead, -1, -1);
	}

	/**
	 * JPQL Query - findDocumentosByCo030fead
	 *
	 */

	@SuppressWarnings("unchecked")
	@Transactional
	public Set<Documentos> findDocumentosByCo030fead(java.util.Calendar co030fead, int startResult, int maxRows) throws DataAccessException {
		Query query = createNamedQuery("findDocumentosByCo030fead", startResult, maxRows, co030fead);
		return new LinkedHashSet<Documentos>(query.getResultList());
	}

	/**
	 * JPQL Query - findDocumentosByCo030load
	 *
	 */
	@Transactional
	public Set<Documentos> findDocumentosByCo030load(String co030load) throws DataAccessException {

		return findDocumentosByCo030load(co030load, -1, -1);
	}

	/**
	 * JPQL Query - findDocumentosByCo030load
	 *
	 */

	@SuppressWarnings("unchecked")
	@Transactional
	public Set<Documentos> findDocumentosByCo030load(String co030load, int startResult, int maxRows) throws DataAccessException {
		Query query = createNamedQuery("findDocumentosByCo030load", startResult, maxRows, co030load);
		return new LinkedHashSet<Documentos>(query.getResultList());
	}

	/**
	 * JPQL Query - findDocumentosByCo030loadContaining
	 *
	 */
	@Transactional
	public Set<Documentos> findDocumentosByCo030loadContaining(String co030load) throws DataAccessException {

		return findDocumentosByCo030loadContaining(co030load, -1, -1);
	}

	/**
	 * JPQL Query - findDocumentosByCo030loadContaining
	 *
	 */

	@SuppressWarnings("unchecked")
	@Transactional
	public Set<Documentos> findDocumentosByCo030loadContaining(String co030load, int startResult, int maxRows) throws DataAccessException {
		Query query = createNamedQuery("findDocumentosByCo030loadContaining", startResult, maxRows, co030load);
		return new LinkedHashSet<Documentos>(query.getResultList());
	}

	/**
	 * JPQL Query - findDocumentosByCo030codi
	 *
	 */
	@Transactional
	public Documentos findDocumentosByCo030codi(String co030codi) throws DataAccessException {

		return findDocumentosByCo030codi(co030codi, -1, -1);
	}

	/**
	 * JPQL Query - findDocumentosByCo030codi
	 *
	 */

	@Transactional
	public Documentos findDocumentosByCo030codi(String co030codi, int startResult, int maxRows) throws DataAccessException {
		try {
			Query query = createNamedQuery("findDocumentosByCo030codi", startResult, maxRows, co030codi);
			return (abs.domain.Documentos) query.getSingleResult();
		} catch (NoResultException nre) {
			return null;
		}
	}

	/**
	 * JPQL Query - findDocumentosByCo030lomo
	 *
	 */
	@Transactional
	public Set<Documentos> findDocumentosByCo030lomo(String co030lomo) throws DataAccessException {

		return findDocumentosByCo030lomo(co030lomo, -1, -1);
	}

	/**
	 * JPQL Query - findDocumentosByCo030lomo
	 *
	 */

	@SuppressWarnings("unchecked")
	@Transactional
	public Set<Documentos> findDocumentosByCo030lomo(String co030lomo, int startResult, int maxRows) throws DataAccessException {
		Query query = createNamedQuery("findDocumentosByCo030lomo", startResult, maxRows, co030lomo);
		return new LinkedHashSet<Documentos>(query.getResultList());
	}

	/**
	 * JPQL Query - findDocumentosByPrimaryKey
	 *
	 */
	@Transactional
	public Documentos findDocumentosByPrimaryKey(String co030codi) throws DataAccessException {

		return findDocumentosByPrimaryKey(co030codi, -1, -1);
	}

	/**
	 * JPQL Query - findDocumentosByPrimaryKey
	 *
	 */

	@Transactional
	public Documentos findDocumentosByPrimaryKey(String co030codi, int startResult, int maxRows) throws DataAccessException {
		try {
			Query query = createNamedQuery("findDocumentosByPrimaryKey", startResult, maxRows, co030codi);
			return (abs.domain.Documentos) query.getSingleResult();
		} catch (NoResultException nre) {
			return null;
		}
	}

	/**
	 * JPQL Query - findDocumentosByCo030descContaining
	 *
	 */
	@Transactional
	public Set<Documentos> findDocumentosByCo030descContaining(String co030desc) throws DataAccessException {

		return findDocumentosByCo030descContaining(co030desc, -1, -1);
	}

	/**
	 * JPQL Query - findDocumentosByCo030descContaining
	 *
	 */

	@SuppressWarnings("unchecked")
	@Transactional
	public Set<Documentos> findDocumentosByCo030descContaining(String co030desc, int startResult, int maxRows) throws DataAccessException {
		Query query = createNamedQuery("findDocumentosByCo030descContaining", startResult, maxRows, co030desc);
		return new LinkedHashSet<Documentos>(query.getResultList());
	}

	/**
	 * JPQL Query - findAllDocumentoss
	 *
	 */
	@Transactional
	public Set<Documentos> findAllDocumentoss() throws DataAccessException {

		return findAllDocumentoss(-1, -1);
	}

	/**
	 * JPQL Query - findAllDocumentoss
	 *
	 */

	@SuppressWarnings("unchecked")
	@Transactional
	public Set<Documentos> findAllDocumentoss(int startResult, int maxRows) throws DataAccessException {
		Query query = createNamedQuery("findAllDocumentoss", startResult, maxRows);
		return new LinkedHashSet<Documentos>(query.getResultList());
	}

	/**
	 * JPQL Query - findDocumentosByCo030codiContaining
	 *
	 */
	@Transactional
	public Set<Documentos> findDocumentosByCo030codiContaining(String co030codi) throws DataAccessException {

		return findDocumentosByCo030codiContaining(co030codi, -1, -1);
	}

	/**
	 * JPQL Query - findDocumentosByCo030codiContaining
	 *
	 */

	@SuppressWarnings("unchecked")
	@Transactional
	public Set<Documentos> findDocumentosByCo030codiContaining(String co030codi, int startResult, int maxRows) throws DataAccessException {
		Query query = createNamedQuery("findDocumentosByCo030codiContaining", startResult, maxRows, co030codi);
		return new LinkedHashSet<Documentos>(query.getResultList());
	}

	/**
	 * JPQL Query - findDocumentosByCo030femoAfter
	 *
	 */
	@Transactional
	public Set<Documentos> findDocumentosByCo030femoAfter(java.util.Calendar co030femo) throws DataAccessException {

		return findDocumentosByCo030femoAfter(co030femo, -1, -1);
	}

	/**
	 * JPQL Query - findDocumentosByCo030femoAfter
	 *
	 */

	@SuppressWarnings("unchecked")
	@Transactional
	public Set<Documentos> findDocumentosByCo030femoAfter(java.util.Calendar co030femo, int startResult, int maxRows) throws DataAccessException {
		Query query = createNamedQuery("findDocumentosByCo030femoAfter", startResult, maxRows, co030femo);
		return new LinkedHashSet<Documentos>(query.getResultList());
	}

	/**
	 * JPQL Query - findDocumentosByCo030femo
	 *
	 */
	@Transactional
	public Set<Documentos> findDocumentosByCo030femo(java.util.Calendar co030femo) throws DataAccessException {

		return findDocumentosByCo030femo(co030femo, -1, -1);
	}

	/**
	 * JPQL Query - findDocumentosByCo030femo
	 *
	 */

	@SuppressWarnings("unchecked")
	@Transactional
	public Set<Documentos> findDocumentosByCo030femo(java.util.Calendar co030femo, int startResult, int maxRows) throws DataAccessException {
		Query query = createNamedQuery("findDocumentosByCo030femo", startResult, maxRows, co030femo);
		return new LinkedHashSet<Documentos>(query.getResultList());
	}

	/**
	 * JPQL Query - findDocumentosByCo030femoBefore
	 *
	 */
	@Transactional
	public Set<Documentos> findDocumentosByCo030femoBefore(java.util.Calendar co030femo) throws DataAccessException {

		return findDocumentosByCo030femoBefore(co030femo, -1, -1);
	}

	/**
	 * JPQL Query - findDocumentosByCo030femoBefore
	 *
	 */

	@SuppressWarnings("unchecked")
	@Transactional
	public Set<Documentos> findDocumentosByCo030femoBefore(java.util.Calendar co030femo, int startResult, int maxRows) throws DataAccessException {
		Query query = createNamedQuery("findDocumentosByCo030femoBefore", startResult, maxRows, co030femo);
		return new LinkedHashSet<Documentos>(query.getResultList());
	}

	/**
	 * Used to determine whether or not to merge the entity or persist the entity when calling Store
	 * @see store
	 * 
	 *
	 */
	public boolean canBeMerged(Documentos entity) {
		return true;
	}
}
